package cn.fscode.sign.client;

import cn.fscode.sign.client.crypto.AsymmetricCryptoManager;
import cn.fscode.sign.client.crypto.BaseAsymmetricCrypto;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/**
 * @author shenguangyang
 */
@Configuration
public class SignConfig {
    @Resource
    private SignatureProperties signatureProperties;

    @Bean(name = "signatureAsymmetricCryptoManager")
    public AsymmetricCryptoManager asymmetricCryptoManager() {
        return new AsymmetricCryptoManager();
    }

    @Bean(name = "signatureAsymmetricCrypto")
    public BaseAsymmetricCrypto baseAsymmetricCrypto(AsymmetricCryptoManager signatureAsymmetricCryptoManager) {
        return signatureAsymmetricCryptoManager.getAsymmetricCrypto(signatureProperties.getSignType());
    }
}
